package com.gitee.loyo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 充电设备接口状态
 */
@Getter
@AllArgsConstructor
public enum ConnectorStatus {
    OFFLINE(0, "离网"), IDLE(1, "空闲"), TAKEN(2, "占用(未充电)"), CHARGING(3, "占用(充电中)"), ORDERED(4, "占用(预约锁定)"), FAULT(255, "故障");

    private int code;
    private String text;

    public static ConnectorStatus valueOf(int code){
        switch (code){
            case 0: return OFFLINE;
            case 1: return IDLE;
            case 2: return TAKEN;
            case 3: return CHARGING;
            case 4: return ORDERED;
            case 255: return FAULT;
        }
        throw new UnsupportedOperationException("unknown code: " + code);
    }
}
